package cn.icanci.task.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @Author: icanci
 * @ProjectName: Spring-Boot-Cases
 * @PackageName: cn.icanci.task.service
 * @Date: Created in 2020/7/18 12:33
 * @ClassAction: 异步任务 编写 Service ,给需要执行的异步任务添加 ` @Async`注解即可
 */
@Service
public class AsyncService {
    /**
     * 告诉 Spring 这是一个异步的方法
     */
    @Async
    public void hello() {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("数据正在处理...");
    }
}